package com.nervenets.web.redis.domain.user;

import com.nervenets.web.enumeration.OperateType;
import com.nervenets.web.enumeration.WealthType;
import com.nervenets.web.redis.RedisSetDomain;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 操作分类统计
 * Created by Joe on 2018/1/25.
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class WealthOfMoneyByOperateType extends RedisSetDomain {
    private long userId;
    private WealthType wealthType;
    private OperateType operateType;
    private long total = 0;
    private int times = 0;

    public WealthOfMoneyByOperateType(long userId, OperateType operateType, WealthType wealthType) {
        this.userId = userId;
        this.operateType = operateType;
        this.wealthType = wealthType;
    }

    @Override
    public String getField() {
        return String.valueOf(userId);
    }

    @Override
    public String getKey() {
        return String.format("WEALTH_OF_OPERATE_TYPE_%s_%s", operateType.getName().toUpperCase(), wealthType.getName().toUpperCase());
    }

    public void add(long offset) {
        this.total += offset;
        this.times++;
    }

}
